<template>
  <div class="patient-rule">
    <el-row class="contnet" :gutter="20">
      <el-col :span="12">
        <el-card class="box-card">
          <p>
            <el-button
              :type="reportFlag === 1 ? 'primary' : ''"
              circle
              class="el-icon-check"
              @click="checkRadio(1)"
            ></el-button>
            <b>需要报告</b>
          </p>
          <img src="@/assets/images/oper/case/report.png" alt="" />
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card class="box-card">
          <p>
            <el-button
              :type="reportFlag === 0 ? 'primary' : ''"
              circle
              class="el-icon-check"
              @click="checkRadio(0)"
            ></el-button>
            <b>不需要报告</b>
          </p>
          <img src="@/assets/images/oper/case/report-no.png" alt="" />
        </el-card>
      </el-col>
    </el-row>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="reportSubmit">确认</el-button>
      <el-button @click="close(false)">取消</el-button>
    </div>
  </div>
</template>

<script>
import { queryPatientPut } from '@/api/operPatient';
import { crud } from '@crud/crud';
export default {
  mixins: [crud()],
  data() {
    return {
      reportFlag: 0
    };
  },
  mounted() {
    this.reportFlag = this.crud.selections[0].reportFlag;
  },
  methods: {
    checkRadio(v) {
      this.reportFlag = v;
    },
    close(v) {
      this.$emit('closeDialog', v);
    },
    reportSubmit() {
      const params = {
        medicalRecordId: this.crud.selections[0].id,
        reportFlag: this.reportFlag
      };
      queryPatientPut('medicalRecord/setReportFlag', params)
        .then((res) => {
          this.crud.editSuccessNotify();
          this.close(true);
        })
        .catch((er) => {});
    }
  }
};
</script>
<style scoped lang='scss'>
.patient-rule {
  > .contnet {
    overflow: hidden;
    padding: 0 42px 20px;
    .el-icon-check {
      padding: 5px;
      font-size: 17px;
      font-weight: bold;
    }
    b {
      margin-left: 6px;
      font-size: 16px;
    }
    img {
      width: 100%;
      margin-top: 20px;
    }
  }
}
</style>
